package com.wing.bill.controller.app;

import com.wing.bill.service.CabinetFormService;
import com.wing.common.utils.JsonResult;
import com.wing.web.utils.JwtUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@Validated
@Api(value = "App-刀具柜报表", tags = "#/bill/cabinet")
@RestController("cabinetFormAppController")
@RequestMapping("bill/app/cabinetForm")
@RequiredArgsConstructor
public class CabinetFormController {

    private final CabinetFormService cabinetFormService;



    @ApiOperation(value = "刀具柜报表顶部数据", notes = "搜索")
    @ApiImplicitParams({

    })
    @GetMapping("/list")
    public JsonResult list(@RequestParam("type")String type,Integer categoryType){
        String code = JwtUtils.getEnterpriseCode();
        HashMap map1 = cabinetFormService.queryNewTwo(type,code);//领新数量和金额
        HashMap map2 = cabinetFormService.queryExistInfo(categoryType);//售刀柜刀具数和金额
        HashMap map3 = cabinetFormService.queryOtherInfo(type,code);//告警数和盘验
        HashMap map4 = cabinetFormService.queryNewInfo(code);//顶部今日领新数和金额
        HashMap map5 = cabinetFormService.queryInNum(type,code);//上货数量
        HashMap map = new HashMap();
        map.put("title","小程序顶部数据");
        map.putAll(map1);
        map.putAll(map2);
        map.putAll(map3);
        map.putAll(map4);
        map.putAll(map5);
        return JsonResult.success("查询成功",map);
    }

    //0123 往前一月往前一周当月当日
    @ApiOperation(value = "刀具消耗情况按人员", notes = "搜索")
    @GetMapping("/queryCabinetByName")
    public JsonResult queryCabinetByName(@RequestParam("type")String type){
        List<HashMap> list = cabinetFormService.queryCabinetByNameInfo(type,JwtUtils.getEnterpriseCode());//刀具消耗情况按人员
        return JsonResult.success("查询成功",list);
    }

    @ApiOperation(value = "刀具消耗情况按刀具型号", notes = "搜索")
    @GetMapping("/queryCabinetByType")
    public JsonResult queryCabinetByType(@RequestParam("type")String type){
        List<HashMap> list = cabinetFormService.queryCabinetByTypeInfo(type,JwtUtils.getEnterpriseCode());//刀具消耗情况按刀具型号
        return JsonResult.success("查询成功",list);
    }

    @ApiOperation(value = "刀具消耗情况按使用设备", notes = "搜索")
    @GetMapping("/queryCabinetByMachine")
    public JsonResult queryCabinetByMachine(@RequestParam("type")String type){
        List<HashMap> list = cabinetFormService.queryCabinetByMachineInfo(type,JwtUtils.getEnterpriseCode());//刀具消耗情况按使用设备
        return JsonResult.success("查询成功",list);
    }




}
